package org.spring.springboot.app.file.task;

import org.apache.commons.lang3.StringUtils;
import org.spring.springboot.app.file.dao.CompanyDao;
import org.spring.springboot.app.file.domain.po.CompanyPO;

import java.math.BigDecimal;

public class CompanyThread extends Thread {
    private CompanyDao companyDao;
    private CompanyPO companyPO;
    private BigDecimal fileSize;
    public CompanyThread(CompanyDao dao,CompanyPO companyPO,BigDecimal fileSize)
    {
        this.companyDao=dao;
        this.companyPO=companyPO;
        this.fileSize=fileSize;
    }

    @Override
    public void run() {
        if(StringUtils.isBlank(companyPO.getStorageNum())){
            companyPO.setStorageNum(BigDecimal.ZERO.toString());
        }
        companyPO.setStorageNum(new BigDecimal(companyPO.getStorageNum()).add(fileSize).toString());
        companyDao.updateByPrimaryKeySelective(companyPO);
    }
}
